<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>网页开关灯</title>
    <script src="js/jquery-3.3.1.min.js"></script>
</head>


<body>
    <input type="button" class="selector" value="关灯">

    <script>
        $(function() {
            $('.selector').click(function() {
                if ($('.selector').val() == '关灯') {
                    $('body').css('backgroundColor', 'black')
                    $('.selector').val('开灯')
                } else {
                    $('body').css('backgroundColor', 'white')
                    $('.selector').val('关灯')
                }

            })
        })
    </script>
</body>

</html>